import React, {
  createContext, useContext,
} from 'react';
import { inject } from 'mobx-react';

  interface ContextProps {
      intlPrefix: string,
      prefixCls: string
  }

  interface StoreProviderProps {
    children: React.ReactElement
  }

const Store = createContext({} as ContextProps);

export function useStore() {
  return useContext(Store);
}

export const StoreProvider = inject('AppState')((props: StoreProviderProps) => {
  const {
    children,
  } = props;

  const value = {
    ...props,
    intlPrefix: 'c7ncd.continuousDeployment.operation',
    prefixCls: 'c7ncd-continuousDeployment-operation',
  };
  return (
    <Store.Provider value={value}>
      {children}
    </Store.Provider>
  );
});
